//package com.sporch.notification;
//
//import com.sporch.event.FirstKaaClientStateListener;
//import org.junit.Test;
//import org.junit.runner.RunWith;
//import org.kaaproject.kaa.client.DesktopKaaPlatformContext;
//import org.kaaproject.kaa.client.Kaa;
//import org.kaaproject.kaa.client.KaaClient;
//import org.kaaproject.kaa.client.notification.UnavailableTopicException;
//import org.kaaproject.kaa.client.profile.ProfileContainer;
//import org.kaaproject.kaa.common.endpoint.gen.Topic;
//import org.kaaproject.kaa.schema.sample.profile.OS;
//import org.kaaproject.kaa.schema.sample.profile.Profile;
//import org.springframework.boot.test.context.SpringBootTest;
//import org.springframework.test.context.junit4.SpringRunner;
//
//import java.io.IOException;
//import java.util.List;
//import java.util.concurrent.Executors;
//import java.util.concurrent.ScheduledExecutorService;
//
///**
// * @Author: czy
// * @Date: 2019/6/6 16:25
// */
//@RunWith(SpringRunner.class)
//@SpringBootTest
//public class Notification {
//
//    @Test
//    public void notificationTest() throws UnavailableTopicException {
//        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);
//        DesktopKaaPlatformContext desktopKaaPlatformContext = new DesktopKaaPlatformContext();
//        FirstKaaClientStateListener firstKaaClientStateListener = new FirstKaaClientStateListener();
//        KaaClient kaaClient = Kaa.newClient(desktopKaaPlatformContext, firstKaaClientStateListener, true);
//
//        //初始化客户端配置
//        Profile profile = new Profile("id", OS.Linux, "3.17", "0.0.1-SNAPSHOT");
//        kaaClient.setProfileContainer(new ProfileContainer() {
//            @Override
//            public Profile getProfile() {
//                return profile;
//            }
//        });
//
//        //启动kaa
//        kaaClient.start();
//
//        //获取所有通知主题
//        List<Topic> topics = kaaClient.getTopics();
//        for (Topic topic : topics) {
//            if ("Android notifications".equals(topic.getName())){
//                //订阅通知
//                kaaClient.subscribeToTopic(topic.getId(),true);
//            }
//        }
//
//        BasicNotificationListener listener = new BasicNotificationListener();
//
//
//        //添加通知监听
//        kaaClient.addNotificationListener(listener);
//
//        System.out.println("--= Press any key to exit =--");
//        try {
//            System.in.read();
//        } catch (final IOException e) {
//            System.out.println("IOException has occurred: {}" + e.getMessage());
//        }
//        System.out.println("Stopping Event Emitter...");
//        executorService.shutdown();
//        kaaClient.stop();
//    }
//}
